package com.atde._03_creational_design_patterns.fcatory.simplefactory.pizzastore.order;


import com.atde._03_creational_design_patterns.fcatory.simplefactory.pizzastore.pizza.CheesePizza;
import com.atde._03_creational_design_patterns.fcatory.simplefactory.pizzastore.pizza.GreekPizza;
import com.atde._03_creational_design_patterns.fcatory.simplefactory.pizzastore.pizza.PepperPizza;
import com.atde._03_creational_design_patterns.fcatory.simplefactory.pizzastore.pizza.Pizza;

/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde._03_creational_design_patterns.fcatory.simplefactory.pizzastore.order
 * @Author: Del
 * @CreateTime: 2025-06-02  23:45
 * @Description: 披萨订购案例 ---  解决OCP问题  --- 引出简单工厂模式
 * @Version: 1.0
 */
public class SimpleFactory {
    
    /*** 
     * @author: Del
     * @date: 2025/6/2 23:51
     * @param orderType 订单类型
     * @return Pizza 返回披萨实例
     * @description: 简单工厂根据订单类型创建对应的披萨
     */
    public Pizza CreatePizza(String orderType) {
        System.out.println("使用简单工厂模式");
        Pizza pizza = null;
        return switch (orderType) {
            case "greek" -> pizza = new GreekPizza();
            case "cheese" -> pizza = new CheesePizza();
            case "pepper" -> pizza = new PepperPizza();
            default -> pizza;
        };
    }
}
